#include "../include/head.h"

//连接服务器
int tcp_connect(char *ip,int port){
    int fd_server = socket(AF_INET,SOCK_STREAM,0);
    ERROR_CHECK(fd_server,-1,"socket");

    struct sockaddr_in serAddr;
    memset(&serAddr,0,sizeof(serAddr));
    serAddr.sin_family = AF_INET;
    serAddr.sin_port = htons(port);
    serAddr.sin_addr.s_addr = inet_addr(ip);
    int ret_connect = connect(fd_server,(struct sockaddr*)&serAddr,sizeof(serAddr));
    ERROR_CHECK(ret_connect,-1,"connect");
    
    return fd_server;

}
